<!DOCTYPE html>     
    
<head>     
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Fixed Positioning Example</title>     
<meta name="viewport" content="width=device-width, initial-scale=1">     
<link rel="stylesheet" href="http://code.jquery.com/mobile/latest/jquery.mobile.min.css" /> 
<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>     
<script src="http://code.jquery.com/mobile/latest/jquery.mobile.min.js"></script>  
<script>
		function submin(){
			var user = new Object();
			user.username = $("#zhanghao").val();
			user.password = $("#mima").val();
			var json = JSON.stringify(user);
			console.log(json)
			$(document).ready(function(){
				$.ajax({
					url : "http://localhost:8080/User/login",//请求的网址
					type : "post",//请求方式
					dataType : "json",//数据格式
					contentType : "application/json;charset=UTF-8",
					data : json,
					success : function(data){
						if(data == 'error'){
							alert('用户名或密码错误')
						}else {
							localStorage.setItem("s",data.username);
							console.log(data);
							window.location.href = "index1.html";
						}
						
					},
					error: function(msg){
						alert("用户名或密码错误");
					}
				});
			});
		}
					
	</script>
</head>               
<body>
	<div data-role="page">
		<div data-role="content">
			<img src="img/kk.jpg" style="width:50%; margin-left:25%;"/>
			<form action="#" method="post"> 
				<input type="text" name="zhanghao" id="zhanghao" placeholder="用户名："  />
				<input type="password" name="mima" id="mima" placeholder="密码："  />
				<a data-role="button" data-theme="a" id="login" onclick="submin()">登录</a>
			</form>
		</div>
    </div>
</body>
</html>
